package com.zhongyu.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongyu.pojo.Goods;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface GoodsMapper extends BaseMapper<Goods> {

    @Select("SELECT t1.* ,t2.pro_Name,t3.type1  FROM smbms_goods t1 JOIN smbms_provider t2 ON t1.provider_id=t2.id JOIN smbms_goods_type t3 ON t1.type_id=t3.id ${ew.customSqlSegment}")
    @ResultMap("GoodsRm")
    List<Goods> findAll(Page page, @Param("ew") Wrapper wrapper);

    @Select("SELECT t2.pro_Name FROM smbms_goods t1 JOIN smbms_provider t2 ON t1.provider_id=t2.id")
    List<Goods> findByDto(String providerId);
    @Select("SELECT TYPE1 FROM smbms_goods t1 JOIN smbms_goods_type t2 ON t1.type_id=t2.id")
    List<Goods> findByDt(String typeId);
    @Select("SELECT id,`name` FROM smbms_goods")
    List<Goods> selectName();
@Select("SELECT * FROM smbms_goods WHERE provider_id=#{providerId}")
    List<Goods> selectProviderId(Integer providerId);

@Select("SELECT * FROM smbms_goods WHERE NAME=#{name}")
   Goods selectChaName(String name);
@Select("SELECT * FROM smbms_goods WHERE id=#{id}")
  Goods  searchDui(Integer id);
}
